﻿using System;
using System.IO;
using System.Reflection;

using MiP.Common;

namespace MiP.XmlCmd.Shell.Commands
{
    public class HelpCommand : Command
    {
        private readonly ILogger _logger;

        public HelpCommand(ILogger logger)
        {
            if (logger == null)
                throw new ArgumentNullException("logger");
            _logger = logger;
        }

        public override void Execute()
        {
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof (HelpCommand), "HelpText.txt"))
            {
                if (stream == null)
                    throw new InvalidOperationException("Internal error: could not find help text.");

                using (TextReader reader = new StreamReader(stream))
                {
                    string text = reader.ReadToEnd();
                    _logger.Info(text);
                }
            }
        }
    }
}